﻿#pragma once

#include <QWidget>
#include "ui_PlayAndRecordRTSPStreamWindow.h"
#include <QCloseEvent>
#include <QString>
#include <thread>
#include <chrono>
#include <QDebug>
#include <QTimer>
#include "../task/YDemuxerTask.h"
#include "../task/YMuxerTask.h"
#include "../task/YDecoderTask.h"
#include "../../sdl/render/IVideoRenderView.h"

class PlayAndRecordRTSPStreamWindow : public QWidget
{
	Q_OBJECT

public:
	void OnRenderView();
	PlayAndRecordRTSPStreamWindow(QWidget* parent = nullptr);
	~PlayAndRecordRTSPStreamWindow();

protected:
	// 重写关闭事件处理函数
	void closeEvent(QCloseEvent* event) override;
public slots:
	void StartPlay();
	void SelectOutputFilePath();
	void SelectInputFilePath();
	void OnPaternChanged(int);
	void OnTimeout();

private:
	Ui::PlayAndRecordRTSPStreamWindow ui;
	QString inputFilePath;
	QString outputFilePath;
	YDemuxerTask* demuxerTask = nullptr;
	YMuxerTask* muxerTask = nullptr;
	YDecoderTask* decoderTask = nullptr;
	IVideoRenderView* view = nullptr;
	QTimer* timer = nullptr;
	std::thread renderThread;
	bool isRunning = false;
	int pattern_type = 0;//模式：0仅播放 1仅录制 2播放并且录制
private:
	void Release();

};
